package com.shell.guard.security;

import java.util.Collection;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

public class CustomUserDetails implements UserDetails {
	static final long serialVersionUID = -7588980448693010399L;
	private String username;
	private String password;
	private boolean enabled = true;
	private String userId;
	private String clientId;
	private String ent;
	private String terminalCode;
	private Collection<? extends GrantedAuthority> authorities;

	public String getClientId() {
		return this.clientId;
	}

	public void setClientId(String clientId) {
		this.clientId = clientId;
	}

	public String getUserId() {
		return this.userId;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
		this.authorities = authorities;
	}

	public String getEnt() {
		return this.ent;
	}

	public void setEnt(String ent) {
		this.ent = ent;
	}

	public String getTerminalCode() {
		return this.terminalCode;
	}

	public void setTerminalCode(String terminalCode) {
		this.terminalCode = terminalCode;
	}

	public Collection<? extends GrantedAuthority> getAuthorities() {
		return this.authorities;
	}

	public String getPassword() {
		return this.password;
	}

	public String getUsername() {
		return this.username;
	}

	public boolean isAccountNonExpired() {
		return true;
	}

	public boolean isAccountNonLocked() {
		return true;
	}

	public boolean isCredentialsNonExpired() {
		return true;
	}

	public boolean isEnabled() {
		return this.enabled;
	}

	public static class CustomUserDetailsBuilder {
		private CustomUserDetails userDetails = new CustomUserDetails();

		public CustomUserDetailsBuilder withUsername(String username) {
			this.userDetails.setUsername(username);
			this.userDetails.setAuthorities(null);
			return this;
		}

		public CustomUserDetailsBuilder withPassword(String password) {
			this.userDetails.setPassword(password);
			return this;
		}

		public CustomUserDetailsBuilder withClientId(String clientId) {
			this.userDetails.setClientId(clientId);
			return this;
		}

		public CustomUserDetailsBuilder withUserId(String userId) {
			this.userDetails.setUserId(userId);
			return this;
		}

		public CustomUserDetailsBuilder withEnt(String ent) {
			this.userDetails.setEnt(ent);
			return this;
		}

		public CustomUserDetailsBuilder withTerminalCode(String terminalCode) {
			this.userDetails.setTerminalCode(terminalCode);
			return this;
		}

		public CustomUserDetails build() {
			return this.userDetails;
		}
	}
}
